<%@ page language="java" pageEncoding="ISO-8859-1"%>

<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-template" prefix="template" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-nested" prefix="nested" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html locale="true">
  <head>
    <html:base />
    
    <title>AddPostalCode.jsp</title>

	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<script type="text/javascript">

function checkblank(f)
{
   fpc=f.pc.value
   fpon=f.pon.value
   
   if((fpc.length==0) || (fpon.length==0))
   {
      alert("pls fill all d fields")
      if(fpc.length==0)
      {
         document.getElementById("lpc").innerHTML="<font color=red>This field shdnt be left blank</font>"
      }
      if(fpon.length==0)
      {
         document.getElementById("lpon").innerText="This field shdnt be left blank"
      }
      return false;
  }
  else
  {
    if((fpc.length<6) || (fpc.length>6))
    {
      alert("Invalid postal code");
      return false;
    }
  }    
}
</script>
  </head>
  
  <body bgcolor="pink">
 <%
 
 Object ob1=request.getAttribute("DATA");
 
  %>
 <html:form action="apca" onsubmit="return checkblank(this)">
<div align="center">
	<table border="0" width="60%">
	<%
		if(ob1!=null){
		 %>
	<tr>
			<td align="center"><u>Add postal code</u></td>
			<td> </td>
			<td></td>
		</tr>
		
	
	
		<tr>
			<td>Postal Code</td>
			<td><html:text property="pc" value=""></html:text> </td>
			<td><label id=lpc></label> </td>
		</tr>
		
		
		
		<tr>
			<td>Post Office Name</td>
			<td><html:text property="pon" value=""></html:text> </td>
			<td><label id=lpon></label> </td>
		</tr>
		<tr>
			<td colspan="2">&nbsp;</td>
		</tr>
		<tr>
			<td colspan="2"><html:submit value="ADD" property="apcp"></html:submit> </td>
		</tr>
		
		<tr>
			<td colspan="2"><a href="">view/edit</a></td>
		</tr>
		<tr>
			<td colspan="2"><%=ob1.toString() %></td>
		</tr>
		<%}
		else{ %>
		
		<tr>
			<td align="center"><u>Add postal code</u></td>
			<td> </td>
			<td></td>
		</tr>
		
	
	
		<tr>
			<td>Postal Code</td>
			<td><html:text property="pc" ></html:text> </td>
			<td><label id=lpc></label> </td>
		</tr>
		
		<tr>
			<td>Post Office Name</td>
			<td><html:text property="pon"></html:text> </td>
			<td><label id=lpon></label> </td>
		</tr>
		<tr>
			<td colspan="2">&nbsp;</td>
		</tr>
		<tr>
			<td colspan="2"><html:submit value="ADD" property="apcp"></html:submit> </td>
		</tr>
		
		<tr>
			<td colspan="2"><a href="">view/edit</a></td>
		</tr>
		
		<%} %>
		
	</table>
</div>
</html:form>
   
   
  </body>
</html:html>
